package com.ybfenpan.controller.admin.sys;


import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.model.ParamWage;
import com.ybfenpan.service.ParamWageService;
import com.ybfenpan.utils.MapUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * Created by Administrator on 2016/3/25.
 */
@Controller
 
public class ParamWageShowController extends BaseController {
    @Resource
    private ParamWageService paramWageService;
   
    @RequestMapping("admin/sys/paramWageShow.shtml")
    public String show(HttpServletRequest request) throws Exception{
        Map formMap = getParameterMap(request);
        int id = MapUtil.getIntValue(formMap, "id");
        if(0 < id){
        	ParamWage paramWage = paramWageService.getByKey(id);
           
            request.setAttribute("paramWage",paramWage);
        }
        return "admin/sys/paramWageShow";
       
    }
     

    @RequestMapping("admin/sys/paramWageUpdate.shtml")
    public String delete(ParamWage paramWage, HttpServletRequest request, ModelMap model) throws Exception{
        Map formMap = getParameterMap(request);
        int id = MapUtil.getIntValue(formMap, "id");
       
        if(0 < id){
        	Map mapParamWage = new HashMap();
        	mapParamWage.put("id",id);   
        	mapParamWage.put("title",MapUtil.getString(formMap,"title"));
        	mapParamWage.put("value",MapUtil.getDoubleValue(formMap,"value"));
        	paramWageService.update(mapParamWage);
            setMessage(model,"更新成功！");
            request.setAttribute("paramWage",paramWage);
            
        }
        return "admin/sys/paramWageShow";
       
    }
}
